package com.qianli.user.enums;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: sm
 * Date: 2017/3/1
 * Time: 上午10:57
 */
public enum EducationEnum {
    UNDER_HIGHSCHOOL(1, "Undergraduate"),
    HIGHSCHOOL(2, "Diploma"),
    JUNIOR(3, "Professional Degree"),
    BACHELOR(4, "Postgraduate Degree"),
    MASTER(5, "PhD"),
    DOCTOR(6, "Other");

    private Integer type;
    private String desc;

    EducationEnum(Integer type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public Integer getType() {
        return type;
    }

    public EducationEnum setType(Integer type) {
        this.type = type;
        return this;
    }

    public String getDesc() {
        return desc;
    }

    public EducationEnum setDesc(String desc) {
        this.desc = desc;
        return this;
    }

    public static List<String> userEducationEnumList() {
        List<String> list = new ArrayList<>();
        for (EducationEnum enumObj : EducationEnum.values()) {
            list.add(enumObj.getDesc());
        }
        return list;
    }

    public static List<String> getDescList() {
        List<String> list = new ArrayList<>();
        for (EducationEnum enumObj : EducationEnum.values()) {
            list.add(enumObj.getDesc());
        }
        return list;
    }

    public static EducationEnum getEnumByType(Integer type) {
        EducationEnum userEducationEnum = null;
        for (EducationEnum enumObj : EducationEnum.values()) {
            if (enumObj.getType().equals(type)) {
                userEducationEnum = enumObj;
                break;
            }
        }
        return userEducationEnum;
    }
    
    public static EducationEnum getEnumByDesc(String desc) {
        EducationEnum userEducationEnum = null;
        for (EducationEnum enumObj : EducationEnum.values()) {
            if (enumObj.getDesc().equals(desc)) {
                userEducationEnum = enumObj;
                break;
            }
        }
        return userEducationEnum;
    }
}
